#ifndef MESSAGESESSION_H
#define MESSAGESESSION_H
#include <QEvent>
#include <messageitem.h>
#include <xmppmanager.h>

#include <gloox/messagehandler.h>
#include <gloox/messageeventhandler.h>
#include <gloox/chatstatehandler.h>
class QObject;

class MessageEvent : public QEvent
{
public:
    MessageEvent()
        :QEvent((QEvent::Type)EVENT_MESSAGE_RECEIVED)
    {
    }
    MessageItem& messageItem(){return message;}
private:
    MessageItem message;
};

class MessageSession : public gloox::MessageHandler,
public gloox::MessageEventHandler,
public gloox::ChatStateHandler
{
public:
    MessageSession(gloox::MessageSession *_session);
    void setEventHandler(QObject* handler);
    void send(QString item);
    void close();


protected:
    virtual void 	handleMessage (const gloox::Message &msg, gloox::MessageSession *session=0);
    virtual void 	handleMessageEvent (const gloox::JID &from,gloox::MessageEventType event);
    virtual void 	handleChatState (const gloox::JID &from, gloox::ChatStateType state);

private:
    gloox::MessageSession *session;
    QObject* eventHandler;

};

#endif // MESSAGESESSION_H
